package entity;

import java.util.ArrayList;
import java.util.List;
/**discard牌堆类
 * 
 * @author zekdot
 *
 */
public class Discard extends PokerPile {
	public Discard(List<Poker> list) {
		for(int i=0;i<list.size();i++)	//将所有牌正面朝上
			list.get(i).setUp(true);
		this.pokerList=list;	//为保存扑克的列表赋值
	}
	@Override
	public boolean put(List<Poker> pokers) {
		return false;	//Discard是不能放入牌的
	}

	@Override
	public List<Poker> get(int i) {
		//System.out.println(i);
		if(i!=pokerList.size()-1)	//如果不是取最后一张
			return null;
		List<Poker> res=pokerList.subList(pokerList.size()-1, pokerList.size());	//首先分割出要拿走的牌，只有一张
		//List<Poker> tempList=new ArrayList<>();
		//for(Poker poker:)
		pokerList=pokerList.subList(0, pokerList.size()-1);	//然后将拿走之后剩下的牌组赋给Discard类成员
		return res;
	}
	/**根据难度改写返回规则
	 * 
	 * @param i
	 * @param level
	 * @return
	 */
	public List<Poker> get(int i,int level){
		if(level<1){	//如果难度等级小于1
			List<Poker> result=new ArrayList<>();
			result.add(pokerList.get(i));
			List<Poker> temp=new ArrayList<>();
			for(int j=0;j<pokerList.size();j++)
				if(j!=i)
					temp.add(pokerList.get(j));
			pokerList=temp;
			//System.out.println(result);
			return result;
		}
		return get(i);
	}
	/*public static void main(String[] args) {
		List<Poker> list=new ArrayList<>();
		list.add(new Poker(2, Suit.Diamond));	//方片2
		list.add(new Poker(4, Suit.Heart));	//红桃4
		list.add(new Poker(7, Suit.Club));	//梅花7
		Discard test=new Discard(list);
		List<Poker> res=test.get(2);
		System.out.println(res==null?"不能取牌":res.get(0));
		System.out.println(test);
	}*/

}
